package meiyunting.shiwuzhaoling.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Consul服务注册与发现配置
 */
@Configuration
@EnableDiscoveryClient
public class ConsulConfig {
    
    @Value("${spring.application.name:lost-found-service}")
    private String applicationName;
    
    @Value("${server.port:8081}")
    private int serverPort;
    
    /**
     * 自定义元数据，可以添加额外信息便于服务治理
     * 这些元数据会在application.properties中通过
     * spring.cloud.consul.discovery.metadata.xxx=yyy的方式使用
     */
    @Bean
    public Map<String, String> customMetadata() {
        Map<String, String> metadata = new HashMap<>();
        metadata.put("version", "1.0");
        metadata.put("group", "lost-found");
        metadata.put("region", "default");
        return metadata;
    }
} 